<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:g="http://giava.by/common/base"
	template="/WEB-INF/layout/t.xhtml">

	<ui:define name="title">
		<h:outputText value="Gestione Partecipante" />
	</ui:define>
	<ui:define name="roles">
		<f:attribute name="roles" value="exhibition" />
	</ui:define>

	<ui:define name="content">

		<script type="text/javascript"
			src="#{request.contextPath}/scripts/it_editor.js"></script>

		<script language="javascript" type="text/javascript"
			src="#{request.contextPath}/scripts/tiny_mce/tiny_mce.js"></script>
		<center>
			<h:form>
				<p:panel header="Gestione Partecipante">
					<script language="javascript" type="text/javascript">
						tinyMCE
								.init({
									// General options
									mode : "specific_textareas",
									language : "it",
									entity_encoding : "named",
									theme : "advanced",
									editor_selector : "tinyMceTa",
									convert_urls : false,
									plugins : "fullscreen,advlink,print,contextmenu,paste,directionality,noneditable,visualchars,nonbreaking,xhtmlxtras,template,table",
									// Theme options ... ho tolto il pulsante imgBrows.. in notizie si mettono tramite il form di upload sotto, no?
									theme_advanced_buttons1 : "fullscreen,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,fontsizeselect,fontselect,|,hr,|,cut,copy,paste,pastetext,pasteword,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,cleanup,|,code",
									theme_advanced_buttons2 : "tablecontrols,|,link,unlink",
									theme_advanced_buttons3 : "",
									theme_advanced_toolbar_location : "top",
									theme_advanced_toolbar_align : "left",
									theme_advanced_fonts : "Arial=Arial;Courier New=Courier New;Times New Roman=Times New Roman;",
									theme_advanced_resizing : true,
									setup : function(ed) {
										<f:verbatim rendered="#{not copertina}">
										// Add a custom button
										ed
												.addButton(
														'imgBrows',
														{
															title : 'Browser immagini',
															image : '#{facesContext.externalContext.request.contextPath}/images/img.gif',
															onclick : function() {
																// Add you own code to execute something on click
																ed.focus();
																//										ed.selection.setContent('<div id="imgHere" style="text-align:center;"></div>');
																var popupWindow = window
																		.open(
																				'#{request.contextPath}/private/page/imagesTiny.jsf',
																				"Browser immagini",
																				"height=600,width=800,modal=yes,alwaysRaised=yes")
																popupWindow.tinyEditor = ed;
															}
														});
										</f:verbatim>
									}
								});
					</script>
					<h:panelGrid columns="2" style="width: 95%">
						<h:outputLabel for="exhibition" value="Esposizione (*):"
							style="width: 100%;" />
						<h:selectOneMenu id="exhibition" style="width: 100%;"
							value="#{participantController.element.exhibition.id}"
							required="true">
							<f:selectItems value="#{exhibitionItems}" />
						</h:selectOneMenu>

						<h:outputLabel for="artist" value="Artista (*):"
							style="width: 100%;"
							rendered="#{participantController.element.subject.type eq 'ART'}" />
						<h:selectOneMenu id="artist" style="width: 100%;"
							value="#{participantController.element.subject.id}"
							required="true"
							rendered="#{participantController.element.subject.type eq 'ART'}">
							<f:selectItems value="#{artistItems}" />
						</h:selectOneMenu>

						<h:outputLabel for="dscipline" value="Disciplina: (*)"
							style="width: 100%;" />
						<h:selectOneMenu id="dscipline" style="width: 100%;"
							value="#{participantController.element.discipline.id}"
							required="true">
							<f:selectItems value="#{disciplineItems}" />
						</h:selectOneMenu>




						<h:outputLabel for="institute" value="Istituto: (*)"
							style="width: 100%;"
							rendered="#{participantController.element.subject.type eq 'INS'}" />
						<h:selectOneMenu id="institute" style="width: 100%;"
							value="#{participantController.element.subject.id}"
							required="true"
							rendered="#{participantController.element.subject.type eq 'INS'}">
							<f:selectItems value="#{instituteItems}" />
						</h:selectOneMenu>

						<h:outputLabel for="museum" value="Museo: (*)"
							style="width: 100%;"
							rendered="#{participantController.element.subject.type eq 'MUS'}" />
						<h:selectOneMenu id="museum" style="width: 100%;"
							value="#{participantController.element.subject.id}"
							required="true"
							rendered="#{participantController.element.subject.type eq 'MUS'}">
							<f:selectItems value="#{museumItems}" />
						</h:selectOneMenu>

						<h:outputLabel for="testimonial" value="Testimonial: (*)"
							style="width: 100%;"
							rendered="#{participantController.element.subject.type eq 'TES'}" />
						<h:selectOneMenu id="testimonial" style="width: 100%;"
							value="#{participantController.element.subject.id}"
							required="true"
							rendered="#{participantController.element.subject.type eq 'TES'}">
							<f:selectItems value="#{testimonialItems}" />
						</h:selectOneMenu>

						<h:outputLabel for="sponsor" value="Sponsor: (*)"
							style="width: 100%;"
							rendered="#{participantController.element.subject.type eq 'SPO'}" />
						<h:selectOneMenu id="sponsor" style="width: 100%;"
							value="#{participantController.element.subject.id}"
							required="true"
							rendered="#{participantController.element.subject.type eq 'SPO'}">
							<f:selectItems value="#{sponsorItems}" />
						</h:selectOneMenu>

						<h:outputLabel for="description" value="Descrizione: "
							style="width: 100%;" />
						<h:inputTextarea id="description" cols="20" rows="20"
							value="#{participantController.element.description}"
							style=" height : 166px; width: 100%;" styleClass="tinyMceTa" />



						<h:outputLabel for="address" value="indirizzo: "
							style="width: 100%;"
							rendered="#{(participantController.element.subject.type eq 'INS') or (participantController.element.subject.type eq 'MUS')}" />
						<h:inputText id="address"
							value="#{participantController.element.address}"
							style="width: 100%;"
							rendered="#{(participantController.element.subject.type eq 'INS') or (participantController.element.subject.type eq 'MUS')}" />

						<h:outputLabel for="city" value="Citta': " style="width: 100%;"
							rendered="#{(participantController.element.subject.type eq 'INS') or (participantController.element.subject.type eq 'MUS')}" />
						<h:inputText id="city"
							value="#{participantController.element.city}"
							style="width: 100%;"
							rendered="#{(participantController.element.subject.type eq 'INS') or (participantController.element.subject.type eq 'MUS')}" />

						<h:outputLabel for="province" value="Provincia: "
							style="width: 100%;"
							rendered="#{(participantController.element.subject.type eq 'INS') or (participantController.element.subject.type eq 'MUS')}" />
						<h:inputText id="province"
							value="#{participantController.element.province}"
							style="width: 100%;"
							rendered="#{(participantController.element.subject.type eq 'INS') or (participantController.element.subject.type eq 'MUS')}" />


						<h:outputLabel for="phone" value="Telefono: " style="width: 100%;" />
						<h:inputText id="phone"
							value="#{participantController.element.phone}"
							style="width: 100%;" />

						<h:outputLabel for="email" value="Email: " style="width: 100%;" />
						<h:inputText id="email"
							value="#{participantController.element.email}"
							style="width: 100%;" />




						<h:outputLabel for="oeuvreTitle" value="Titolo opera: "
							style="width: 100%;"
							rendered="#{participantController.element.subject.type eq 'ARS'}" />
						<h:inputText id="oeuvreTitle"
							value="#{participantController.element.oeuvreTitle}"
							style="width: 100%;"
							rendered="#{participantController.element.subject.type eq 'ARS'}" />

						<h:outputLabel for="dimensions" value="Dimensioni: "
							style="width: 100%;"
							rendered="#{participantController.element.subject.type eq 'ARS'}" />
						<h:inputText id="dimensions"
							value="#{participantController.element.dimensions}"
							style="width: 100%;"
							rendered="#{participantController.element.subject.type eq 'ARS'}" />

						<h:outputLabel for="material" value="Materiale e tecnica: "
							style="width: 100%;"
							rendered="#{participantController.element.subject.type eq 'ARS'}" />
						<h:inputTextarea id="material" cols="20" rows="20"
							value="#{participantController.element.material}"
							style=" height : 166px; width: 100%;"
							rendered="#{participantController.element.subject.type eq 'ARS'}" />


						<h:outputLabel for="summary" value="summary: "
							style="width: 100%;"
							rendered="#{participantController.element.subject.type eq 'ARS'}" />
						<h:inputTextarea id="summary" cols="20" rows="20"
							value="#{participantController.element.summary}"
							style=" height : 166px; width: 100%;"
							rendered="#{participantController.element.subject.type eq 'ARS'}" />


						<h:outputLabel for="discipline" value="Disciplina: (*)"
							style="width: 100%;"
							rendered="#{participantController.element.subject.type eq 'ARS'}" />
						<h:selectOneMenu id="discipline" style="width: 100%;"
							value="#{participantController.element.discipline.id}"
							required="true"
							rendered="#{participantController.element.subject.type eq 'ARS'}">
							<f:selectItems value="#{disciplineItems}" />
						</h:selectOneMenu>

						<h:outputLabel for="participationType"
							value="Tipo Partecipazione: (*)" style="width: 100%;" />
						<h:selectOneMenu id="participationType" style="width: 100%;"
							value="#{participantController.element.participationType}"
							required="true">
							<f:selectItems value="#{participationTypeItems}" />
						</h:selectOneMenu>

						<h:outputLabel for="webSite" value="Sito web: "
							style="width: 100%;" />
						<h:inputText id="webSite"
							value="#{participantController.element.webSite}"
							style="width: 100%;" />

						<h:outputLabel for="facebookAccount" value="Account Facebook: "
							style="width: 100%;" />
						<h:inputText id="facebookAccount"
							value="#{participantController.element.facebookAccount}"
							style="width: 100%;" />

						<h:outputLabel for="twitterAccount" value="Account Twitter: "
							style="width: 100%;" />
						<h:inputText id="twitterAccount"
							value="#{participantController.element.twitterAccount}"
							style="width: 100%;" />

						<h:outputLabel for="instagramAccount" value="Account Instagram: "
							style="width: 100%;" />
						<h:inputText id="instagramAccount"
							value="#{participantController.element.instagramAccount}"
							style="width: 100%;" />

						<h:outputLabel for="externalImage" value="External Image: "
							style="width: 100%;" />
						<h:inputText id="externalImage"
							value="#{participantController.element.externalImage}"
							style="width: 100%;" />

						<h:outputLabel for="date" value="Data: " style="width: 100%;" />
						<h:inputText id="date"
							value="#{participantController.element.date}"
							style="width: 100%;" />

						<h:outputLabel value="Immagine:" for="image"
							rendered="#{not empty participantController.element.image}" />
						<h:graphicImage id="image"
							value="/img/#{participantController.element.image.filename}"
							alt="#{participantController.element.image.filename}"
							title="#{participantController.element.image.filename}"
							style="padding: 5px;"
							rendered="#{not empty participantController.element.image}" />
					</h:panelGrid>
					<br />
				</p:panel>

				<h:panelGrid columns="5">

					<h:commandButton action="#{participantController.save}"
						value="Salva" immediate="false"
						rendered="#{not participantController.editMode}" />

					<h:commandButton
						action="#{participantController.saveAndModifyImage}"
						value="Salva e Modifica Dcumenti" immediate="false"
						rendered="#{not participantController.editMode}" />

					<h:commandButton action="#{participantController.update}"
						value="Salva le modifiche" immediate="false"
						rendered="#{participantController.editMode}" />

					<h:commandButton
						action="#{participantController.updateAndModifyImage}"
						value="Salva le modifiche e Modifica Immagine" immediate="false"
						rendered="#{participantController.editMode}" />

					<h:commandButton action="#{participantController.delete}"
						value="Elimina" rendered="#{participantController.editMode}"
						immediate="true"
						onclick="if (!confirm('Vuoi davvero eliminare?')) return false" />
				</h:panelGrid>
			</h:form>
		</center>


	</ui:define>
</ui:composition>